Members within a structure may be referred to directly using the . (structure member) operator. This operator is used in conjunction with the structure name and the member name you intend to reference in the form:
As mentioned before, structures support the use of static arrays as data members. Arrays within structures present a bit more of a syntactical challenge when referencing a member value, but otherwise they are not difficult to use. To reference a value in an array element within a structure, append the member operator and a member array element reference to the structure instance identifier:
It is also possible to have arrays of structures which have arrays as members. Once again, a combination of the member operator with a reference to the desired array element is used to obtain the data value. In this case, array element references will appear on
both sides of the member operator. This can lead to some rather interesting looking syntax within a script:
Structures containing other structures as members also present an additional layer of complexity when referencing members of the nested structure. The key in this situation is to use member chaining to descend through the data hierarchy to the desired value. For example:
The CIRCLE structure declaration makes use of an instance of the
POINT structure to more logically organize data. To reference either the
x- or
y-component of the
POINT instance, chain the members of the nested structures:
References to the member ctr and its members
x and
y are chained together using the member operator to reference and access the values in the nested structure. Chaining of members in nested structures can be used repeatedly in scripts to access structure members which may be nested several levels deep.